import type { RefundTaxSettleVO, RefundTaxSettleForm, RefundTaxSettleQuery } from './model';

import type { ID, IDS } from '#/api/common';
import type { PageResult } from '#/api/common';

import { commonExport } from '#/api/helper';
import { requestClient } from '#/api/request';

/**
* 查询退税结算列表
* @param params
* @returns 退税结算列表
*/
export function refundTaxSettleList(params?: RefundTaxSettleQuery) {
  return requestClient.get<PageResult<RefundTaxSettleVO>>('/trade/refundTaxSettle/list', { params });
}

/**
 * 导出退税结算列表
 * @param params
 * @returns 退税结算列表
 */
export function refundTaxSettleExport(params?: RefundTaxSettleQuery) {
  return commonExport('/trade/refundTaxSettle/export', params ?? {});
}

/**
 * 查询退税结算详情
 * @param id id
 * @returns 退税结算详情
 */
export function refundTaxSettleInfo(id: ID) {
  return requestClient.get<RefundTaxSettleVO>(`/trade/refundTaxSettle/${id}`);
}

/**
 * 查询退税结算详情
 * @param id id
 * @returns 退税结算详情
 */
export function refundTaxSettleInfoByOrderId(orderId: ID) {
  return requestClient.get<RefundTaxSettleVO>(`/trade/refundTaxSettle/getInfoByOrderId/${orderId}`);
}


/**
 * 新增退税结算
 * @param data
 * @returns void
 */
export function refundTaxSettleAdd(data: RefundTaxSettleForm) {
  return requestClient.postWithMsg<void>('/trade/refundTaxSettle', data);
}

/**
 * 更新退税结算
 * @param data
 * @returns void
 */
export function refundTaxSettleUpdate(data: RefundTaxSettleForm) {
  return requestClient.putWithMsg<void>('/trade/refundTaxSettle', data);
}

/**
 * 删除退税结算
 * @param id id
 * @returns void
 */
export function refundTaxSettleRemove(id: ID | IDS) {
  return requestClient.deleteWithMsg<void>(`/trade/refundTaxSettle/${id}`);
}

/**
 * 提交退税结算
 * @param ids id数组
 * @returns void
 */
export function refundTaxSettleSubmit(ids: IDS) {
  return requestClient.postWithMsg<void>('/trade/refundTaxSettle/submit', ids);
}

/**
 * 审核退税结算
 * @param id id
 * @param passed 是否通过
 * @param rejectReason 驳回原因
 * @returns void
 */
export function refundTaxSettleApprove(id: ID, passed: boolean, rejectReason?: string) {
  return requestClient.postWithMsg<void>('/trade/refundTaxSettle/approve', {
    id,
    passed,
    rejectReason,
  });
}

/**
 * 作废退税结算
 * @param id id
 * @returns void
 */
export function refundTaxSettleInvalidate(id: ID) {
  return requestClient.postWithMsg<void>(`/trade/refundTaxSettle/invalidate/${id}`);
}
